import React, {useState,useEffect} from 'react';
import axios from "axios";
import {
    Link
} from "react-router-dom";

function Home(props) {
    const [info,setInfo] = useState([]);
    useEffect(()=>{
        axios.get("/info").then(value=>{
            // console.log(value.data);
            setInfo(value.data);
        })
    },[])
    return (
        <div>
            {
                info.map(item=>(
                    <div key={item.id}>
                        新闻ID：{item.id}
                        新闻标题：<Link to={"/detail/"+item.id}>{item.title}</Link>
                    </div>
                ))
            }
        </div>
    );
}

export default Home;